#include <iostream>
using namespace std;
int main ()
{int k,a[100];
 while(cin>>k)
 {if(k==-1) break;
  int sum=0,m;a[0]=0;
  for(int i=1;i<=k;i++)
  {cin>>m>>a[i];
   sum=sum+m*(a[i]-a[i-1]);
   }
   cout<<sum<<" "<<"miles"<<endl;
}
  system("pause"); 
  return 0;
}
